import React, { Component } from 'react'
import { ListBox } from '../../../components'


import { fetchData } from '../../../components/AjaxConsumer'
import { Button, Modal, Form, Input, Radio, Upload, Icon } from 'antd';
export default class ListProCheckHis extends Component {
    constructor(props) {
        super(props);
        this.state = {
            tableColumn: {},
            searchComponentData: [],
            visible: false,
        };
        //行操作列表
        this.rowOperation = [

        ];
        //header 操作列表
        this.headerOperation = [

        ];

        //table列表展示列配置
        //showName、columnName 必有属性， columnWidth 可选，默认100, columnHidden: true 列隐藏
        this.tableColumn = {
            storageKey: 'listLockLog',
            data: [
                {
                    showName: 'storageSnChkHisId',
                    columnName: 'storageSnChkHisId',
                    columnHidden: true,
                    foreverHidden: true
                }, {
                    showName: '合同编号',
                    columnName: 'contractNo',
                    columnWidth: 150
                }, {
                    showName: '条码',
                    columnName: 'barcode',
                    columnWidth: 160
                }, {
                    showName: '型号',
                    columnName: 'model',
                    columnWidth: 130
                }, {
                    showName: '型号类型',
                    columnName: 'modelType',
                    columnWidth: 110
                }, {
                    showName: '单位',
                    columnName: 'unit',
                    columnWidth: 80
                }, {
                    showName: '数量',
                    columnName: 'amount',
                    columnWidth: 80
                }, {
                    showName: '状态',
                    columnName: 'barcodeStatus',
                    showOption: [//页面显示配置
                        {
                            optionKey: '0',
                            optionShow: '可用'
                        }, {
                            optionKey: '1',
                            optionShow: '冻结'
                        }, {
                            optionKey: '2',
                            optionShow: '已出库'
                        }, {
                            optionKey: '3',
                            optionShow: '抽检冻结'
                        }
                    ],
                    columnWidth: 80
                }, {
                    showName: '发货质检状态',
                    columnName: 'checkStatus',
                    showOption: [//页面显示配置
                        {
                            optionKey: '0',
                            optionShow: '未质检'
                        }, {
                            optionKey: '1',
                            optionShow: '质检合格'
                        }, {
                            optionKey: '2',
                            optionShow: '质检不合格'
                        }
                    ],
                    columnWidth: 120
                },
                {
                    showName: '冻结原因',
                    columnName: 'lockReason',
                    showOption: [//页面显示配置
                    ]
                }, 
                {
                    showName: '质检人',
                    columnName: 'createBy',
                    columnWidth: 100
                }, 
                {
                    showName: '质检时间',
                    columnName: 'gmtCheck',
                    columnWidth: 135
                }, 
                // {
                //     showName: '排产时间',
                //     columnName: 'proPlanDate'
                // },
                //{
                //    showName: '仓库',
                //    columnName: 'whCode'
                //}, {
                //    showName: '区域',
                //    columnName: 'wdCode'
                //}, {
                //    showName: '库区',
                //    columnName: 'waCode'
                //},
                
                {
                    showName: ' 库位',
                    columnName: 'wlCode'
                }
            ]
        };

        //搜索属性配置
        this.searchComponentData = [
            {
                showName: '型号类型',
                name: 'modelType',
                type: 'select',
                optionList: [
                ]
            }, {
                showName: '状态',
                name: 'barcodeStatus',
                type: 'select',
                optionList: [
                    {
                        optionKey: '',
                        optionShow: ''
                    }, {
                        optionKey: '0',
                        optionShow: '可用'
                    }, {
                        optionKey: '1',
                        optionShow: '冻结'
                    }, {
                        optionKey: '2',
                        optionShow: '已出库'
                    }, {
                        optionKey: '3',
                        optionShow: '报废'
                    }
                ]
            },{
                showName: '冻结原因',
                name: 'lockReason',
                type: 'select',
                optionList: [
                    
                ]
            },{
                name:'amount',
                type: 'number',
                maxName:'amountMax',
                minName:'amountMin'
            },
            {
                showName: '质检时间',
                name: 'gmtCheck',
                type: 'date',
                maxName: 'gmtCheckMax', //最大值
                minName: 'gmtCheckMin'  //最小值
            },{
                showName: '发货质检状态',
                name: 'checkStatus',
                type: 'select',
                optionList: [
                    {
                        optionKey: '',
                        optionShow: ''
                    },
                     {
                        optionKey: '0',
                        optionShow: '未质检'
                    }, {
                        optionKey: '1',
                        optionShow: '质检合格'
                    }, {
                        optionKey: '2',
                        optionShow: '质检不合格'
                    }
                ]
            }
        ];

    }

    rowHandles = (strHandles, rowObj) => {
    }

    //刷新列表
    refreshHandle = () => {
        this.refs.listWorkarea.refreshHandle();
    }

    componentWillMount() {
        const dicType = 'model_type_p';
        const options= {
            url: '/base/dic/get/' + dicType,
            type: 'get',
            condition:{}
        };
        //先写死，后面再改
        fetchData(this, options, this.dicInitCallBackHandle);

        const dicType1 = 'defet_type_p';
        const options1= {
            url: '/base/dic/get/' + dicType1,
            type: 'get',
            condition:{}
        };
        //先写死，后面再改
        fetchData(this, options1, this.dicInitCallBackHandle1);
    }

    //下拉框 初始化
    dicInitCallBackHandle = (resData)=>{
        //alert('resData' + JSON.stringify(resData, null, 4));
        let optionList = [];
        let tmp = {};
        tmp.optionKey = '';
        tmp.optionShow = '';
        optionList.push(tmp);
        resData.data.map( (e,index) => {
            let tmp = {};
            tmp.optionKey = e.dicCode;
            tmp.optionShow = e.dicName;
            optionList.push(tmp);
        });

        //alert('optionList' + JSON.stringify(optionList, null, 4));
        this.tableColumn.data[4].showOption = optionList;
        this.searchComponentData[0].optionList = optionList;
    }

    dicInitCallBackHandle1 = (resData)=>{
        //alert('resData' + JSON.stringify(resData, null, 4));
        let optionList = [];
        let tmp = {};
        tmp.optionKey = '';
        tmp.optionShow = '';
        optionList.push(tmp);
        resData.data.map( (e,index) => {
            let tmp = {};
            tmp.optionKey = e.dicCode;
            tmp.optionShow = e.dicName;
            optionList.push(tmp);
        });

        //alert('optionList' + JSON.stringify(optionList, null, 4));
        this.tableColumn.data[9].showOption = optionList;
        this.searchComponentData[2].optionList = optionList;
    }

    render() {
        //当左侧隐藏时，列表宽度加上左侧的宽度，
        //1、当前this.props.isHideLeft 是从页面组件containers/Main/main.js传过来
        //2、this.props.isHideLeft 最顶级赋值是在页面 containers/Main/main.js
        let isHideLeft = this.props.isHideLeft;

        return (
            <div>
                <ListBox
                    ref='ListProCheckHis'
                    title="成品发货质检历史查询"
                    isHideLeft={isHideLeft}
                    tableColumnData={this.tableColumn}
                    searchComponentData={this.searchComponentData}
                    url='/product/check/his/list'
                    rowHandles={this.rowHandles}
                    rowOperation={this.rowOperation}
                    headerOperation={this.headerOperation}
                    isRowSingle="true"
                />
            </div>
        )
    }
}
